<!DOCTYPE html>
<%@page import="br.com.megaacerto.dto.UsuarioLogadoDTO"%>
<html ng-app="plunker">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<link href="/megaacerto/style/css/bootstrapSpaceLab.css"
	rel="stylesheet">

<link rel="stylesheet" type="text/css"
	href="/megaacerto/style/css/styles.css" />

</head>

<body ng-controller="Boloes">
	<div ng-include src="'/megaacerto/page/menu.jsp'"></div>

	<div id="wrap">
		<div id="main" class="container clear-top">
			<div class="row">
				<div class="jumbotron" ng-show="mostrarBoloes" ng-init="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Mega Sena');">
				<!-- 
				<table class="table table-striped table-hover ">
									<thead>
										<tr>
											<th><a href="#" ng-click="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Mega Sena');"><img
													alt="" ng-disable="true" ng-src="../img/btnmegasena.jpg"></a></th>
											<th><a href="#" ng-click="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Quina');"><img
													alt="" ng-src="../img/btnquina.jpg"> </a></th>
											<th><a href="#" ng-click="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Loto Mania');"><img
													alt="" ng-src="../img/bntlotomania.jpg"> </a></th>
											<th><a href="#" ng-click="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Dupla Sena');"><img
													alt="" ng-src="../img/btnduplasena.jpg"> </a></th>
											<th><a href="#" ng-click="carregarBoloes(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId()%>,'Loto Fácil');"><img
													alt="" ng-src="../img/bntlotofacil.jpg"> </a></th>
										</tr>
									</thead>
								</table>
								-->
					<!-- 
					<div class="form-group">
						<label for="inputEstado" class="control-label col-xs-2">Tipo de Jogo</label>
						<div class="col-md-6">
							<select id="estado" ng-model="estado" ng-required="true"
								name="estado" class="form-control">
								<option value="0">Mega Sena</option>
								<option value="1">Quina</option>
								<option value="2">Loto Mania</option>
								<option value="3">Dupla Sena</option>
								<option value="4">Loto Fácil</option>
							</select><button class="btn btn-primary" ng-click="carregarUsuario();">Buscar</button>
						</div>
					</div>
					 -->
					
					<div class="form-group">
						<label class="control-label col-xs-2">Tipo de Jogo</label>
						<div class="col-xs-6">
							<select ng-model="tipoDeJogo" class="form-control" >
								<option value="-1" selected="selected">Todos Bol&otilde;es</option>
								<option value="0">Mega Sena</option>
								<option value="1">Quina</option>
								<option value="2">Loto Mania</option>
								<option value="3">Dupla Sena</option>
								<option value="4">Loto F&aacute;cil</option>
							</select>
						</div><button class="btn btn-primary" ng-click="filtroBoloes()">Buscar</button>
					</div>
					
					<div class="form-group">
							<input ng-change="filtroBoloes()" type="radio" ng-model="filtro" name="filtro" value="-1">Sorteados/Premiados/&Agrave; Sortear
							<input ng-change="filtroBoloes()" type="radio" ng-model="filtro" name="filtro" value="0">&Agrave; Sortear
							<input ng-change="filtroBoloes()" type="radio" ng-model="filtro" name="filtro" value="1">Sorteados
							<input ng-change="filtroBoloes()" type="radio" ng-model="filtro" name="filtro" value="2">Premiados
					</div>
					
					<table class="table table-striped table-hover ">
						<thead>
							<tr>
								<th>Identificador</th>
								<th>Jogos</th>
								<th>Valor cota</th>
								<th>Quantidade</th>
								<th>Total</th>
								<th>Data Compra</th>
								<th>Data Sorteio</th>
								<th>Situacao</th>
							</tr>
						</thead>
						<tbody ng-repeat="compraBolaoUsuario in compraBolaoUsuarios">
							<!-- <tr ng-show="compraBolaoUsuario.tipoDeJogo == tipoDeJogo"> -->
							<tr>
								<td>{{compraBolaoUsuario.identificadorGrupo}}</td>
								<td><a data-toggle="modal" href="#myModal"
									ng-click="carregarJogos(compraBolaoUsuario);"><img alt=""
										ng-src="/megaacerto/img/lupa-mini.png"> </a></td>
								<td>{{compraBolaoUsuario.valorCota | currency:'R$'}}</td>
								<td>{{compraBolaoUsuario.qtdCota}}</td>
								<td>{{compraBolaoUsuario.valorCota * compraBolaoUsuario.qtdCota | currency:'R$'}}</td>
								<td>{{compraBolaoUsuario.dtCompra}}</td>
								<td>{{compraBolaoUsuario.dtSorteio}}</td>
								<td><a ng-show="compraBolaoUsuario.situacao" href='#' ng-click='carregarResultados(compraBolaoUsuario);' >Premiado</a>
								<span ng-show="!compraBolaoUsuario.situacao"  >-</span></td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="modal" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<span><b>MegaAcerto - {{legenda}}</b></span>
								<button type="button" class="close" data-dismiss="modal">
									<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
								</button>
								<!-- <h4 class="modal-title" id="myModalLabel"><!--CARREGAR DINAMICO Mega Sena</h4> -->
							</div>
							<div class="modal-body">
								<div class="alert alert-dismissable alert-warning">
									<button type="button" class="close" data-dismiss="alert">×</button>
										<p><b>Indentificador:</b>{{identificadorGrupo}}</p>
								</div>
								
								<div dynamic="descDesdobramento"></div>
								
									<pagination boundary-links="true" total-items="totalItems"
										data-current-page="currentPage" data-max-size="maxSize"
										ng-model="currentPage" class="pagination-sm"
										data-num-pages="numPages()" previous-text="&lsaquo;"
										next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination>

									<div data-pagination="" data-num-pages="numPages()"
										data-current-page="currentPage" data-max-size="maxSize"
										data-boundary-links="true"></div>
									<table class="table table-striped table-hover ">
										<thead>
											<tr>
												<th></th>
												<th>ID</th>
												<th>Jogo</th>
											</tr>
										</thead>
										<tbody ng-repeat="jogo in jogos">
											<tr>
												<td></td>
												<td>{{jogo.id}}</td>
												<td>{{jogo.sequencia}}</td>
											</tr>
										</tbody>
									</table>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default"
									data-dismiss="modal">Fechar</button>
							</div>
						</div>
					</div>
				</div>
				<div class="jumbotron" ng-show="mostrarResultado">
				<h4 ng-show="compraBolaoUsuarios.totalPremio"><p>{{mesagemPremioResgatado}}</p></h4>
					<b>Sequêcia sorteada:</b>  <span>{{seqSorteada}}</span><a href="#" ng-click="carregarBoloes(1)"  class="pull-right"">Voltar</a>
					<table class="table table-striped table-hover ">
							<thead>
								<tr>
									<th>Jogo sorteado</th>
									<th>DESC. Premio</th>
									<th>QTD. Ganhadores</th>
									<th>Valor do Premio</th>
									<th>Multiplicador</th>
									<th>Premio do Bolão</th>
									<th>Total/Cota</th>
								</tr>
							</thead>
							<tbody ng-repeat="resultado in resultados">
								<tr>
									<td>{{resultado.seqJogoPremiado}}</td>
									<td>{{resultado.descTipoDeGanho}}</td>
									<td>{{resultado.qntDeGanhadores}}</td>
									<td>{{resultado.valorDoGanho | currency:'R$'}}</td>
									<td>{{resultado.multiplicador}}</td>
									<td>{{resultado.valorDoGanho | currency:'R$'}}</td>
									<td>{{(resultado.valorDoGanho / totalDeCotas) * qtdCotas | currency:'R$'}}</td>
								</tr>
							</tbody>
					</table><span><h4><b> Valor Total: {{total | currency:'R$'}} </b></h4></span><button ng-show="!compraBolaoUsuarios.totalPremio" ng-click="resgatarPremio(<%=((UsuarioLogadoDTO) session.getAttribute( "usuario" )).getId() %>)" class="btn btn-primary pull-right">Resgatar Premio</button><br/>
					<!-- 
					<table class="table table-striped table-hover ">
						<thead>
							<tr>
								<th>Jogo</th>
								<th>Resultado</th>
								<th>Quantidade de Cotas</th>
								<th>Total Premio</th>
							</tr>
						</thead>
						<tbody ng-repeat="resultado in resultados">
							<tr>
								<td>{{resultado.jogo}}</td>
								<td>{{resultado.resultado}}</td>
								<td>{{resultado.qtdCota}}</td>
								<td>{{resultado.premio | currency:'R$'}}</td>
								<td>{{resultado.premio * resultado.qtdCota | currency:'R$'}}</td>
							</tr>
						</tbody>
					</table>
					<span><h4><b> ValorTotal: {{total | currency:'R$'}} </b></h4></span>
					 -->
				</div>
				<div class="jumbotron" ng-show="premioResgatado">
					<b>Premio resgatado com sucesso.</b> <a href="#" ng-click="carregarBoloes(1)"  class="pull-right"">Voltar</a>
				</div>
				
			</div>
		</div>
	</div>
	<div ng-include src="'/megaacerto/page/footer.html'"></div>

	<!-- PARA FAZER MASCARA FUNCIONAR ANGULAR JS/	-->
	<script src="/megaacerto/javascript/recursos/jquery-1.11.1.js"></script>

	<!-- Latest compiled and minified JavaScript -->
	<script src="/megaacerto/javascript/recursos/bootstrap.min.js"></script>

	<script type="text/javascript"
		src="/megaacerto/javascript/recursos/angular_2.min.js"></script>

	<script src="/megaacerto/javascript/recursos/storageprovider.js"></script>

	<script type="text/javascript"
		src="/megaacerto/javascript/control/angular-route.js"></script>

	<script type="text/javascript"
		src="/megaacerto/javascript/recursos/ui-bootstrap-tpls-0.11.0.min.js"></script>

	<script type="text/javascript"
		src="/megaacerto/javascript/control/boloes.js"></script>
</body>

</html>